package com.fk.his.biznorule.service;

import com.alibaba.cola.dto.SingleResponse;
import com.fk.his.biznorule.service.executor.RuleAddExecutor;
import com.fk.his.biznorule.service.executor.query.BizNoRuleQueryExecutor;
import com.rickie.api.IBizNoRuleService;
import com.rickie.dto.data.BizNoRuleCO;
import com.rickie.dto.data.BizNoRuleAddCmd;
import com.rickie.dto.data.BizNoRuleQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import java.util.List;

/**
 * <p>
 * 业务编码规则应用层
 * <p>
 * 示例代码
 * <pre>
 *
 *  TrackingDomainService领域服务类的代码如下所示：
 * @Service
 * public class TrackingDomainService implements ITrackingDomainService {
 *     @Autowired
 *     private TrackingGateway trackingGateway;
 *
 *     @Override
 *     public void create(TrackingActivity trackingActivity) {
 *         // 分配tracking number
 *         String random = UUID.randomUUID().toString().toUpperCase();
 *         String trackingNumber = random.substring(0, random.indexOf("-"));
 *         trackingActivity.setTrackNumber(trackingNumber);
 *         // 持久化
 *         trackingGateway.save(trackingActivity);
 *     }
 * }
 * </pre/>
 *
 * @author InHome
 * @version BME V100R001 2023/03/27
 * @since BME V100R001C40B104
 */
@Service
//@DubboService
public class BizNoRuleAService implements IBizNoRuleService
{

    @Autowired
    private BizNoRuleQueryExecutor bizNoRuleQueryExecutor;
    @Autowired
    private RuleAddExecutor bizNoRuleAddExecutor;
/*    @DubboReference(group = "demo")
    private IOrderService iOrderService;*/

    @Override
    public SingleResponse<BizNoRuleCO> save(BizNoRuleAddCmd bizNoRuleAddCmd) {
//        System.out.println(iOrderService.test());
        return SingleResponse.of(bizNoRuleAddExecutor.doExecute(bizNoRuleAddCmd));
    }

    @Override
    public List<BizNoRuleCO> findWithPage(@Validated BizNoRuleQuery bizNoRuleQuery) {
        return bizNoRuleQueryExecutor.doExecute(bizNoRuleQuery);
    }
}